﻿using System;

namespace _04.MaximalSequenceOfEqualElementsInArray
{
    class MaximalSequenceOfEqualElementsInArray
    {
        static void Main(string[] args)
        {
            Console.Write("Enter lenght of array:");
            int lenghtOfArray = int.Parse(Console.ReadLine());
            int[] array = new int[lenghtOfArray];
            Console.WriteLine("Enter elements of array.The elements must be integer numbers.");
            int count = 1;
            int newCount = 0;
            int start = 0;
            int newStart = 0;
            for (int i = 0; i < lenghtOfArray; i++)
            {
                array[i] = int.Parse(Console.ReadLine());
            }
            for (int i = 0; i < array.Length - 1; i++)
            {
                if (array[i] == array[i + 1])
                {
                    count++;
                }
                else
                {
                    start = i + 1;
                    count = 1;
                }
                if (newCount <= count)
                {
                    newCount = count;
                    newStart = start;
                }
            }
            for (int i = newStart; i < newStart + newCount; i++)
            {
                Console.Write(array[i] + " ");
            }
        }
    }
}
